package com.accp.vehiclecare.biz.xzhbiz;

import com.accp.vehiclecare.dao.xzhdao.ArmemberDao;
import com.accp.vehiclecare.pojo.Armember;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("ArmemberBiz")
public class ArmemberBiz extends ServiceImpl<ArmemberDao, Armember> {
    /**
     * 新增班组成员
     * @param armember
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean addArmember(Armember armember){
        QueryWrapper<Armember> qw = new QueryWrapper<Armember>();
        qw.eq("ararmemberno",armember.getArarmemberno());
        int cou = super.baseMapper.selectCount(qw);
        int count;
        if(cou>0){
            return false;
        }else {
            count =super.baseMapper.insert(armember);
        }
        return count!=0;
    }

    /**
     * 修改班组成员
     * @param armember
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean amendArmember(Armember armember){
        int count=super.baseMapper.updateById(armember);
        return count !=0;
    }

    /**
     * 删除班组员工
     * @param id
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean removeArmember(Integer id){
        int count=super.baseMapper.deleteById(id);
        return count !=0;
    }
}
